/**
 * Created by huangchao on 10/01/2018.
 */


import H from '../helper/helper';
import { userTypeVerDoAjax } from '../detail/detail';
import config from '../config';

var $joblist = $('.w-joblist');



/**
 *  超长文本截断
 */
// 多行
$joblist.find('.job-child .abstract').each(function() {
  var $me = $(this);
  $me.html(H.substring($me.text(), 255));
});


// 低版本单行兼容
if (!$('body').css('maxWidth')) {
  $('.w-joblist .job-child').each(function() {
    var $self = $(this),
      $job = $self.find('.base .job a'),
      $hotel = $self.find('.base .hotel a');

    $job.html(H.substring($job.html(), 33)).css('width', '');
    $hotel.html(H.substring($hotel.html(), 24));
  });
}


/**
 * 关键字标红
 */
// var keyWord = _ARR_KEY_WORDS.length ? RegExp('(' + _ARR_KEY_WORDS.join('|') + ')', 'ig') : null;
function keyOut($list) {
  if (keyWord) {
    $list.find('.job a, .hotel a, .attr .brief').each(function() {
      var $me = $(this);
      $me.html($me.html().replace(keyWord, '<b>$1</b>'));
    });
  }
}
// keyOut($joblist);



/**
 * 电话直聘
 */
$joblist.on('click', '.base .job .call', function() {
  userTypeVerDoAjax(config.jsonpBase + '/pop/show_tel', {
    job_id: $(this).closest('.job-child').data('id')
  }, function(data) {
    layer.message('<p>欢迎来电应聘/咨询：<strong>' + data.message.contact_telephone + '</strong><br>咨询时间：' + (data.message.contact_time == '00:00-00:00' ? '24 x 7' : data.message.contact_time) + '</p>', 2, {
      title: '电话直聘'
    });
  });
});